package com.longteng.lesson2.service;

import com.longteng.lesson2.dao.InterfaceTestMapper;
import com.longteng.lesson2.domain.InterfaceTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class InterfaceTestService {
    @Autowired
    InterfaceTestMapper interfaceTestMapper;
    @Transactional(rollbackFor = {ArrayIndexOutOfBoundsException.class,NullPointerException.class})
    public Object test(Integer i) throws Exception{
        InterfaceTest interfaceTest =new InterfaceTest();
        interfaceTest.setInterfaceAliasName("a");
        interfaceTestMapper.addInterfaceTest(interfaceTest);
        if(i!=1){
            throw new Exception();
        }
        return "ss";
    }
}
